home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / objects in c ƒ / Name Sources / NameMixin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-06  |  1.2 KB  |  68 lines  |  [TEXT/KAHL]

  1. /*    
  2.  *        NameMixin abstract class
  3.  *
  4.  *        NameMixin class.  provides objects of inheriting classes with
  5.  *        a name in the global object NameSpace.
  6.  *
  7.  *            Copyright © John Wainwright 1989
  8.  *
  9.  *    SuperClasses :
  10.  *                    
  11.  *  Instance Vars :
  12.  *
  13.  *    Class Vars :
  14.  *                    
  15.  *    Methods :
  16.  *                    
  17.  *    Class Methods :
  18.  *                     
  19.  */
  20.  
  21. #include "oic.h"
  22. #include "generics.h"
  23. #include "names.h"
  24.  
  25. class         NameMixin;            /* the NameMixin class                 */
  26.  
  27. object        namedObjects;        /* the global object namespace        */
  28.  
  29. struct NameMixin_i                /* NameMixin instance structure        */
  30. {
  31.     object    theName;            /* object name                        */
  32. };
  33. typedef struct NameMixin_i NameMixin_i;
  34.  
  35. /* -------------------- NameMixin Instance methods ---------------- */
  36.  
  37. method object
  38. _name(self, n, string)
  39.     object                    self;
  40.     register NameMixin_i    *n;
  41.     register char            **string;
  42. {
  43.     n->theName = declare(Name, *string);
  44.     bind(namedObjects, n->theName, self);
  45. }
  46.  
  47. method object
  48. _nameOf(self, n)
  49.     object                    self;
  50.     register NameMixin_i    *n;
  51. {
  52.     return n->theName;
  53. }
  54.  
  55. /* ------------------- Init the NameMixin class -------------------- */
  56.  
  57. InitNameMixinClass()
  58. {
  59.     NameMixin = NewClass(0, 0, "NameMixin", END);
  60.     AddMethods(NameMixin,
  61.         nameGeneric,         _name,
  62.         nameOfGeneric,         _nameOf,
  63.         END);
  64.         
  65.     namedObjects = New(NameSpace, 256, 0);
  66. }
  67.  
  68.